import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../utils/my_common.dart';

/// 自定义提示组件
/// 使用GetX的SnackBar并应用自定义颜色样式
class CustomSnackBar {
  /// 成功提示
  static void success(String message) {
    // 使用异步方式调用，避免阻塞后续代码
    Future.microtask(() {
      Get.snackbar(
        'Success',
        message,
        backgroundColor: MyCommonUtils.green,
        colorText: MyCommonUtils.white,
        snackPosition: SnackPosition.TOP,
        duration: const Duration(seconds: 2),
        margin: const EdgeInsets.all(16),
        borderRadius: 8,
        isDismissible: true,
      );
    });
  }

  /// 失败提示
  static void error(String message) {
    Future.microtask(() {
      Get.snackbar(
        'Error',
        message,
        backgroundColor: MyCommonUtils.pink,
        colorText: MyCommonUtils.white,
        snackPosition: SnackPosition.TOP,
        duration: const Duration(seconds: 2),
        margin: const EdgeInsets.all(16),
        borderRadius: 8,
        isDismissible: true,
      );
    });
  }

  /// 警告提示
  static void warning(String message) {
    Future.microtask(() {
      Get.snackbar(
        'Warning',
        message,
        backgroundColor: MyCommonUtils.orange,
        colorText: MyCommonUtils.white,
        snackPosition: SnackPosition.TOP,
        duration: const Duration(seconds: 2),
        margin: const EdgeInsets.all(16),
        borderRadius: 8,
        isDismissible: true,
      );
    });
  }
}
